import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '客户编码',
    align:"center",
    dataIndex: 'custCode'
   },
   {
    title: '入库单号',
    align:"center",
    dataIndex: 'orderNo'
   },
   {
    title: '入库单明细id',
    align:"center",
    dataIndex: 'recId'
   },
   {
    title: '数量',
    align:"center",
    dataIndex: 'num'
   },
  //  {
  //   title: '折扣',
  //   align:"center",
  //   dataIndex: 'discount'
  //  },
  //  {
  //   title: '税前单价',
  //   align:"center",
  //   dataIndex: 'costPrice'
  //  },
  //  {
  //   title: '税前折后单价',
  //   align:"center",
  //   dataIndex: 'srcPrice'
  //  },
  //  {
  //   title: '税后单价（折后）',
  //   align:"center",
  //   dataIndex: 'taxPrice'
  //  },
  //  {
  //   title: '税后金额（税后总价）',
  //   align:"center",
  //   dataIndex: 'taxAmount'
  //  },
  //  {
  //   title: '税率',
  //   align:"center",
  //   dataIndex: 'tax'
  //  },
  //  {
  //   title: '税前金额（税前总价）',
  //   align:"center",
  //   dataIndex: 'totalCost'
  //  },
   {
    title: '入库单明细备注',
    align:"center",
    dataIndex: 'remark'
   },
   {
    title: '货品名称',
    align:"center",
    dataIndex: 'goodsName'
   },
   {
    title: '货品编号',
    align:"center",
    dataIndex: 'goodsNo'
   },
   {
    title: '商家编码',
    align:"center",
    dataIndex: 'specNo'
   },
   {
    title: '规格码',
    align:"center",
    dataIndex: 'specCode'
   },
  //  {
  //   title: '采购明细自定义属性1',
  //   align:"center",
  //   dataIndex: 'prop1'
  //  },
  //  {
  //   title: '采购明细自定义属性2',
  //   align:"center",
  //   dataIndex: 'prop2'
  //  },
  //  {
  //   title: '采购明细自定义属性3',
  //   align:"center",
  //   dataIndex: 'prop3'
  //  },
  //  {
  //   title: '采购明细自定义属性4',
  //   align:"center",
  //   dataIndex: 'prop4'
  //  },
   {
    title: '规格名称',
    align:"center",
    dataIndex: 'specName'
   },
   {
    title: '品牌名称',
    align:"center",
    dataIndex: 'brandName'
   },
   {
    title: '基本单位',
    align:"center",
    dataIndex: 'unitName'
   },
   {
    title: '批次',
    align:"center",
    dataIndex: 'batchNo'
   },
   {
    title: '有效期',
    align:"center",
    dataIndex: 'expireDate'
   },
   {
    title: '生产日期',
    align:"center",
    dataIndex: 'productionDate'
   },
   {
    title: '货位',
    align:"center",
    dataIndex: 'positionNo'
   },
  //  {
  //   title: '是否残品 true：是 false：否',
  //   align:"center",
  //   dataIndex: 'defect'
  //  },
  //  {
  //   title: '换算系数',
  //   align:"center",
  //   dataIndex: 'unitRatio'
  //  },
  //  {
  //   title: '辅助单位',
  //   align:"center",
  //   dataIndex: 'purchaseUnitName'
  //  },
  //  {
  //   title: '入库价',
  //   align:"center",
  //   dataIndex: 'stockinPrice'
  //  },
   {
    title: '创建时间',
    align:"center",
    dataIndex: 'gmtCreate'
   },
   {
    title: '修改时间',
    align:"center",
    dataIndex: 'gmtUpdate'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "货品编号",
      field: 'goodsNo',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "批次号",
      field: 'batchNo',
      component: 'Input',
      //colProps: {span: 6},
 	},
    {
    label: "创建时间",
    field: "gmtCreate",
    component: 'RangePicker',
    componentProps: {
      valueType: 'Date',
    },
    //colProps: {span: 6},
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '客户编码',
    field: 'custCode',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入客户编码!'},
          ];
     },
  },
  {
    label: '与主表stockin_id关联',
    field: 'stockinId',
    component: 'InputNumber',
  },
  {
    label: '入库单号',
    field: 'orderNo',
    component: 'Input',
  },
  {
    label: '入库单明细id',
    field: 'recId',
    component: 'InputNumber',
  },
  {
    label: '数量',
    field: 'num',
    component: 'InputNumber',
  },
  {
    label: '折扣',
    field: 'discount',
    component: 'InputNumber',
  },
  {
    label: '税前单价',
    field: 'costPrice',
    component: 'InputNumber',
  },
  {
    label: '税前折后单价',
    field: 'srcPrice',
    component: 'InputNumber',
  },
  {
    label: '税后单价（折后）',
    field: 'taxPrice',
    component: 'InputNumber',
  },
  {
    label: '税后金额（税后总价）',
    field: 'taxAmount',
    component: 'InputNumber',
  },
  {
    label: '税率',
    field: 'tax',
    component: 'InputNumber',
  },
  {
    label: '税前金额（税前总价）',
    field: 'totalCost',
    component: 'InputNumber',
  },
  {
    label: '入库单明细备注',
    field: 'remark',
    component: 'Input',
  },
  {
    label: '货品名称',
    field: 'goodsName',
    component: 'Input',
  },
  {
    label: '货品编号',
    field: 'goodsNo',
    component: 'Input',
  },
  {
    label: '商家编码',
    field: 'specNo',
    component: 'Input',
  },
  {
    label: '规格码',
    field: 'specCode',
    component: 'Input',
  },
  {
    label: '采购明细自定义属性1',
    field: 'prop1',
    component: 'Input',
  },
  {
    label: '采购明细自定义属性2',
    field: 'prop2',
    component: 'Input',
  },
  {
    label: '采购明细自定义属性3',
    field: 'prop3',
    component: 'Input',
  },
  {
    label: '采购明细自定义属性4',
    field: 'prop4',
    component: 'Input',
  },
  {
    label: '规格名称',
    field: 'specName',
    component: 'Input',
  },
  {
    label: '品牌名称',
    field: 'brandName',
    component: 'Input',
  },
  {
    label: '基本单位',
    field: 'unitName',
    component: 'Input',
  },
  {
    label: '若无批次则返回空字符串',
    field: 'batchNo',
    component: 'Input',
  },
  {
    label: '若无有效期则返回空字符串',
    field: 'expireDate',
    component: 'Input',
  },
  {
    label: '若无生产日期则返回空字符串',
    field: 'productionDate',
    component: 'Input',
  },
  {
    label: '货位',
    field: 'positionNo',
    component: 'Input',
  },
  {
    label: '是否残品 true：是 false：否',
    field: 'defect',
    component: 'InputNumber',
  },
  {
    label: '换算系数',
    field: 'unitRatio',
    component: 'InputNumber',
  },
  {
    label: '辅助单位',
    field: 'purchaseUnitName',
    component: 'Input',
  },
  {
    label: '入库价',
    field: 'stockinPrice',
    component: 'InputNumber',
  },
  {
    label: '创建时间',
    field: 'gmtCreate',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入创建时间!'},
          ];
     },
  },
  {
    label: '修改时间',
    field: 'gmtUpdate',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入修改时间!'},
          ];
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  custCode: {title: '客户编码',order: 0,view: 'text', type: 'string',},
  orderNo: {title: '入库单号',order: 2,view: 'text', type: 'string',},
  recId: {title: '入库单明细id',order: 3,view: 'number', type: 'number',},
  num: {title: '数量',order: 4,view: 'number', type: 'number',},
  discount: {title: '折扣',order: 5,view: 'number', type: 'number',},
  costPrice: {title: '税前单价',order: 6,view: 'number', type: 'number',},
  srcPrice: {title: '税前折后单价',order: 7,view: 'number', type: 'number',},
  taxPrice: {title: '税后单价（折后）',order: 8,view: 'number', type: 'number',},
  taxAmount: {title: '税后金额（税后总价）',order: 9,view: 'number', type: 'number',},
  tax: {title: '税率',order: 10,view: 'number', type: 'number',},
  totalCost: {title: '税前金额（税前总价）',order: 11,view: 'number', type: 'number',},
  remark: {title: '入库单明细备注',order: 12,view: 'text', type: 'string',},
  goodsName: {title: '货品名称',order: 13,view: 'text', type: 'string',},
  goodsNo: {title: '货品编号',order: 14,view: 'text', type: 'string',},
  specNo: {title: '商家编码',order: 15,view: 'text', type: 'string',},
  specCode: {title: '规格码',order: 16,view: 'text', type: 'string',},
  prop1: {title: '采购明细自定义属性1',order: 17,view: 'text', type: 'string',},
  prop2: {title: '采购明细自定义属性2',order: 18,view: 'text', type: 'string',},
  prop3: {title: '采购明细自定义属性3',order: 19,view: 'text', type: 'string',},
  prop4: {title: '采购明细自定义属性4',order: 20,view: 'text', type: 'string',},
  specName: {title: '规格名称',order: 21,view: 'text', type: 'string',},
  brandName: {title: '品牌名称',order: 22,view: 'text', type: 'string',},
  unitName: {title: '基本单位',order: 23,view: 'text', type: 'string',},
  batchNo: {title: '若无批次则返回空字符串',order: 24,view: 'text', type: 'string',},
  expireDate: {title: '若无有效期则返回空字符串',order: 25,view: 'text', type: 'string',},
  productionDate: {title: '若无生产日期则返回空字符串',order: 26,view: 'text', type: 'string',},
  positionNo: {title: '货位',order: 27,view: 'text', type: 'string',},
  defect: {title: '是否残品 true：是 false：否',order: 28,view: 'number', type: 'number',},
  unitRatio: {title: '换算系数',order: 29,view: 'number', type: 'number',},
  purchaseUnitName: {title: '辅助单位',order: 30,view: 'text', type: 'string',},
  stockinPrice: {title: '入库价',order: 31,view: 'number', type: 'number',},
  gmtCreate: {title: '创建时间',order: 32,view: 'datetime', type: 'string',},
  gmtUpdate: {title: '修改时间',order: 33,view: 'datetime', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}